<template>
  <el-dialog :title="dataList.test" :visible.sync="dataList.type">
  <el-form :model="dataList">

    <el-form-item label="订单状态" :label-width="formLabelWidth">
        <el-select
            v-model="dataList.order_status"
            clearable
            placeholder="请选择"
            @change="gai"
          >
            <el-option label="未支付" value="0"> </el-option>
            <el-option label="待发货" value="1"> </el-option>
            <el-option label="待收货" value="2"> </el-option>
            <el-option label="待评价" value="3"> </el-option>
            <el-option label="已完成" value="4"> </el-option>
            <el-option label="线下付款" value="5"> </el-option>
          </el-select>
    </el-form-item>

    <el-form-item label="图标" :label-width="formLabelWidth">
        <el-upload
          class="avatar-uploader"
          action=""
          :show-file-list="false"
          :http-request="handleAvatarSuccess"
          :before-upload="beforeAvatarUpload"
          style="width:56px;height:56px;"
        >
          <img style="width:56px;height:56px;" v-if="dataList.pic" :src="dataList.pic" class="avatar" />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
    </el-form-item>

    <el-form-item label="排序" :label-width="formLabelWidth">
        <el-input v-model="dataList.sort" autocomplete="off"></el-input>
    </el-form-item>

    <el-form-item label="状态" :label-width="formLabelWidth">
        <el-radio-group v-model="dataList.status">
          <el-radio :label="1">显示</el-radio>
          <el-radio :label="0">隐藏</el-radio>
        </el-radio-group>
    </el-form-item>

  </el-form>
  <div slot="footer" class="dialog-footer">
    <el-button @click="dataList = false">取 消</el-button>
    <el-button type="primary" @click="sure">确 定</el-button>
  </div>
</el-dialog>
</template>

<script>
import { MemberImage } from "../../api/dataallocation/OrderDetails";
export default {
  props: ["dataList"],
  data() {
    return {
        formLabelWidth: "120px",
        status:"",
        imgs:""
    };
  },

  methods: {
      sure(){
          console.log(this.dataList);
          this.dataList.type=false
          if(this.dataList.id==""){
              this.$emit("addList",this.dataList)
          }else{
              this.$emit("editList",this.dataList)
          }
      },
      handleAvatarSuccess(res, file) {
      let formdata = new FormData();
      formdata.append("pid", 0);
      formdata.append("file", this.imgs);
      MemberImage(formdata).then((res) => {
        if (res.data.status == 200) {
          this.$message({
          message: res.data.msg,
          type: 'success'
        });
          this.dataList.pic = "http://bw.gsruiying.com.cn/" + res.data.data.src;
        }else{
          this.$message({
          message: res.data.msg,
          type: 'error'
        });
        }
      });
    },
    beforeAvatarUpload(file) {
      this.imgs = file;
    },
  },
};
</script>
<style lang='scss' scoped>
</style>